import React,{Component} from "react";
import {StyleSheet, Text, TouchableOpacity, View,NavigatorIOS} from "react-native";

export default class ZxingPage extends Component {
    constructor(props){
        super(props);
        this.state={
            result:"结果显示在这里"
        }
    }
    render() {
        return (
            <View style={MyStyles.container}>
                <TouchableOpacity
                    activeOpacity={1}
                    onPress={()=>{
                        NavigatorIOS.push({
                            activity:"com.journeyapps.barcodescanner.CaptureActivity",
                            requestCode:0x0000c0de
                        }).then((data)=>{
                            console.log(data);
                            this.setState({
                                result:data.SCAN_RESULT
                            });
                        })
                    }}>
                    <Text>
                        点击调用扫码
                    </Text>
                </TouchableOpacity>
                <Text>
                    {this.state.result}
                </Text>
            </View>
        );
    }
}


const MyStyles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
    instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
    },
    wrape: {
        resizeMode: "contain",
        height: 100,
        width: 100
    }
});